<?php

namespace App\Http\Controllers\Mobile;


use App\Logics\CollectLogic;
use App\Logics\EventLogic;
use App\Logics\FanLogic;
use App\Logics\OrderLogic;
use App\Logics\UserAuthLogic;
use App\Logics\UserLogic;


class MyEventController extends BaseController
{
    // 我的活动管理
    public function initialize()
    {
        parent::initialize();
    }

    // 自己添加的
    public function my()
    {
        // 指定用户
        $option = $this->optLogic();
        $option->setField('uid', $this->myUid);

        // 查询
        $logic  = new EventLogic();
        $result = $logic->getLists($this->myUid);
        if($result === false){
            return $this->error($logic->getError());
        }

        return $this->success($result);
    }

    // 自己加入的
    public function join()
    {
        // 指定用户
        $option = $this->optLogic();
        $option->setField('order_uid', $this->myUid);
        $option->setField('add_event', 1);

        // 查询
        $logic  = new OrderLogic();
        $result = $logic->getStudent();
        if($result === false){
            return $this->error($logic->getError());
        }

        return $this->success($result);
    }

    // 活动 上架
    // 活动 下架
    public function onSale()
    {
        $logic  = new EventLogic();
        $result = $logic->onSale($this->myUid);
        if($result === false){
            return $this->error($logic->getError());
        }

        return $this->success($result);
    }

    // 活动 编辑
    public function edit()
    {
        $logic  = new EventLogic();
        $result = $logic->onEdit($this->myUid);
        if($result === false){
            return $this->error($logic->getError());
        }

        return $this->success($result);
    }

    // 活动 添加
    // 发布活动：赛事+研学
    public function publish()
    {
        $logic  = new EventLogic();
        $result = $logic->onAdd($this->myUid);
        if($result === false){
            return $this->error($logic->getError());
        }

        return $this->success($result);
    }

}


